package pers.wwz.study.wechatserver.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import pers.wwz.study.wechatserver.feign.request.SendSubscribeMgRequest;
import pers.wwz.study.wechatserver.feign.respoonse.AccessTokenResponse;
import pers.wwz.study.wechatserver.feign.respoonse.Code2SessionResponse;
import pers.wwz.study.wechatserver.feign.respoonse.SendSubscribeMsgResponse;


@FeignClient(name = "WechatFeign",url = "https://api.weixin.qq.com")

public interface WechatFeign {



    /**
     * 获取accessToken
     * @param appid appid
     * @param secret secret
     * @param grant_type 授权类型
     * @return 结果
     */
    @RequestMapping("/cgi-bin/token")
    AccessTokenResponse getAccessToken(@RequestParam("appid") String appid, @RequestParam("secret") String secret, @RequestParam("grant_type") String grant_type);

    /**
     * 小程序登录
     * @param appid appid
     * @param secret secret
     * @param js_code wx.login获取到的code
     * @param grant_type 授权类型
     * @return 结果
     */
    @RequestMapping("/sns/jscode2session")
    Code2SessionResponse jscode2session(@RequestParam("appid") String appid, @RequestParam("secret") String secret, @RequestParam("js_code") String js_code, @RequestParam("grant_type") String grant_type);


    /**
     * 发送订阅消息
     * @param access_token access_token
     * @param sendSubscribeMgRequest 请求参数
     * @return 结果
     */
    @RequestMapping("/cgi-bin/message/subscribe/send")
    SendSubscribeMsgResponse sendSubscribeMsg(@RequestParam("access_token") String access_token, @RequestBody SendSubscribeMgRequest sendSubscribeMgRequest);

}
